package com.sun.config;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * API方式读取Properties
 */
@Configuration
public class PropertiesConfig {

    @ApolloConfig
    private Config defConfig;

    @ApolloConfig("test-prop")
    private Config testConfig;

    @Bean
    public void configDefault() {
        String apolloParam = defConfig.getProperty("test.param1", "DefaultValue");
        System.out.println("PropertiesConfig test.param1 = " + apolloParam);
    }

    @Bean
    public void configProperties() {
        String apolloParam = testConfig.getProperty("test.param1", "DefaultValue");
        System.out.println("PropertiesConfig test.param1 = " + apolloParam);
    }

}
